import java.lang.reflect.InvocationTargetException;


public class FileSystemTest {
	
	
	public static void testMakeDirectories(FileSystem f) throws InstantiationException,IllegalAccessException,
	SecurityException, InvocationTargetException
	{
		String[] cmd1 = {"mkdir", "/Dir1"};
		String[] cmd2 = {"mkdir", "/Dir1/Dir2"};	
		f.selectFunction(cmd1);
		assert FileSystem.curr_dir.getContents().containsKey("Dir1");
		f.selectFunction(cmd2);			
		Directory directory1 = (Directory) FileSystem.curr_dir.getContents().get("Dir1");
		assert directory1.getContents().containsKey("Dir2");
		System.out.println("Test1 has passed");
	}
	
	public static void testChangeDirectory(FileSystem f) throws InstantiationException,IllegalAccessException,
	SecurityException, InvocationTargetException{
		String[] cmd3 = {"cd", "/Dir1"};
		f.selectFunction(cmd3);
		assert FileSystem.curr_dir.getName().equals("Dir1"): "change dir";
		System.out.println("Test2 has passed");
	}
	
	public static void testEchoWriteToFile(FileSystem f) throws InstantiationException,IllegalAccessException,
	SecurityException, InvocationTargetException{
		String[] cmd10 = {"echo", "contents of file", ">", "outfile.txt"};
		f.selectFunction(cmd10);
		assert FileSystem.curr_dir.getContents().containsKey("outfile.txt");
		File file1 = (File) FileSystem.curr_dir.getContents().get("outfile.txt");
		assert file1.getContents().equals("contents of file");
		System.out.println("Test3 has passed");
	}
	
	public static void main(String args[]) throws SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException{
		FileSystem f = new FileSystem();
		//Test making directory Dir1 and in Dir1 make directory Dir2
		testMakeDirectories(f);
		testChangeDirectory(f);
		testEchoWriteToFile(f);


	}
		
}
